console.log('\'Allo \'Allo!');

(function ($) {
  var compiled = {};
  $.fn.handlebars = function (template, data) {
    if (template instanceof jQuery) {
      template = $(template).html();
    }
    compiled[template] = Handlebars.compile(template);
    this.html(compiled[template](data));
  };
})(jQuery);

$(function () {

  $('#main').html($('#HOME_PAGE_HTML').html());
  var back_home = $('.back_home')
    , BRAND_HISTORY = $('#BRAND_HISTORY')
    , INNOVATIVE_TECH = $('#INNOVATIVE_TECH');

  $('#btn_brand_history').click(function () {
    back_home.fadeIn();
    BRAND_HISTORY.fadeIn();

    // $('#HOME_PAGE').fadeOut();
    banrdPage.init()
  });

  $('#btn_innovative_tech').click(function () {
    back_home.fadeIn();
    INNOVATIVE_TECH.fadeIn();
    tecMainPage.init()
    // $('#HOME_PAGE').fadeOut();
  });
  back_home.click(function () {
    $('.menu').slideToggle()
  });

  $('.GUIDE_RT_01.HOME').click(function () {
    BRAND_HISTORY.fadeOut();
    TweenMax.to(history_list, .4, {x: '100%'});
    INNOVATIVE_TECH.fadeOut();
    TweenMax.to('.TEC_Allterrain', .4, {x: '100%'})
    back_home.fadeOut()
  });

  $('.GUIDE_RT_02.HISTORY').click(function () {
    BRAND_HISTORY.fadeIn();
    TweenMax.to(history_list, .4, {x: '100%'});
    INNOVATIVE_TECH.fadeOut();

  });

  $('.GUIDE_RT_03.TEC').click(function () {
    INNOVATIVE_TECH.fadeIn();
    BRAND_HISTORY.fadeOut();
    // tecMainPage.init();
    TweenMax.to('.TEC_Allterrain', .4, {x: '100%'})
  });

  // brandPage.init();
  // tecMainPage.init()
});

var history_list = $('.history_list');

function historyListSlideToggle() {
  var toggle = history_list.attr('toggle');
  if (toggle === 'hide') {
    history_list.attr('toggle', 'show');
    TweenMax.to(history_list, .4, {x: '0%'});
  }
  if (toggle === 'show') {
    TweenMax.to(history_list, .4, {x: '100%'});
    history_list.attr('toggle', 'hide');
  }

  // if (toggle === undefined) {
  //   TweenMax.set(history_list, {x: '100%'});
  //   history_list.data('toggle', 'hide');
  // }

}
